package projeto;

import java.util.Properties;

import javax.persistence.EntityManagerFactory;

import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

import projeto.entidade.OperacaoFinanceira;

/**
 * Unit test for simple App.
 */
public class EXE_Persistencia {
	public static void main(String[] args) {
		Properties properties = new Properties();
		properties.put("hibernate.connection.username", "USRCRE");
		properties.put("hibernate.connection.password", "123456");
		properties.put("hibernate.connection.driver_class", "com.ibm.db2.jcc.DB2Driver");
		properties.put("hibernate.connection.url", "jdbc:db2://DB2D101:50001/CRE_TBP");
		properties.put("hibernate.dialect", "org.hibernate.dialect.DB2Dialect");
		// properties.put("hibernate.default_catalog","PROJETO");
		properties.put("hibernate.show_sql", "true");
		properties.put("hibernate.format_sql", "true");
		properties.put("hibernate.hbm2ddl.auto", "create-drop");

		Ejb3Configuration ejb = new Ejb3Configuration();
		ejb.addAnnotatedClass(OperacaoFinanceira.class);
		EntityManagerFactory emf = ejb.addProperties(properties).buildEntityManagerFactory();
		SchemaExport schema = new SchemaExport(ejb.getHibernateConfiguration());
		schema.setOutputFile("c:/tmp/schema.sql");
		schema.create(true, true);
		System.out.println(emf);
	}
}
